package com.enjoy.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.PoiOverlay;
import com.baidu.mapapi.search.MKPoiInfo;
import com.baidu.mapapi.search.MKSearch;
import com.enjoy.ui.CreateEvent;
import com.enjoy.ui.FindPlace;

public class MyPoiOverlay extends PoiOverlay {
	Activity activity;
    public MyPoiOverlay(Activity activity, MapView mapView, MKSearch search) {
        super(activity, mapView);
        this.activity=activity;
    }

    @Override
    protected boolean onTap(int i) {
        //super.onTap(i);
        final MKPoiInfo info = getPoi(i);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		
		
		builder.setMessage(info.name+"\n确定是这里");
		builder.setPositiveButton("确定",
				new DialogInterface.OnClickListener() {

					public void onClick(DialogInterface dialog,
							int which) {
						Intent intent = new Intent();
		 				intent.putExtra("longitude",(float)info.pt.getLongitudeE6()/1000000+"");
		 				
		 				Log.i("longitude",(float)info.pt.getLongitudeE6()/1000000+"");
		 				intent.putExtra("longitude",(float)info.pt.getLatitudeE6()/1000000+"");
		 				Log.i("latitude",(float)info.pt.getLatitudeE6()/1000000+"");
		 				
		 				intent.putExtra("placename", info.name);
		 				Log.i("placename",info.name);
		 				
		 				intent.setClass(activity, CreateEvent.class);
		 				activity.startActivity(intent);
					}
				});
		builder.setNegativeButton("取消",null);
		builder.show();
        
//        if (info.hasCaterDetails) {
//            mSearch.poiDetailSearch(info.uid);
//        }
        return true;
    }

    
}
